<?php
/**
 * User: Aven(老甘)
 * Date: 2018-03-21
 * Time: 14:56
 */

namespace app\push\service;

use WebSocket\Client;

class Push
{
    const SOCKET = 'ws://gitee88.com:2346';

    public static function send($data, $id = ''){
        $client = new Client(self::SOCKET);
        $client->send(json_encode(['type' => 'push', 'id' => $id, 'data' => $data]));
        $res = $client->receive();
        return json_decode($res, true);
    }
}